package com.hmall.order.web;


import com.hmall.order.OrderDto;
import com.hmall.order.service.IOrderService;
import com.hmall.order.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("order")
public class OrderController {

   @Autowired
   private IOrderService orderService;

   @GetMapping("{id}")
   public Order queryOrderById(@PathVariable("id") Long orderId) {
      return orderService.getById(orderId);
   }

   /**
    * @param orderDto OrderDto
    * @return Long
    * 提交订单
    */
   @PostMapping
   public Long submit(@RequestBody OrderDto orderDto) {
      Long orderId = orderService.submit(orderDto);
      return orderId;
   }
}
